package com.eliza.base.views.learn.text

import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.material3.Typography
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.googlefonts.Font
import androidx.compose.ui.text.googlefonts.GoogleFont
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import com.eliza.base.R

object FontsX {
    @Composable
    fun Show(navController: NavController) {
        Column {
            var count by remember {
                mutableIntStateOf(0)
            }
            Button(onClick = { count = (count + 1) % 2 }) {
                Text(text = "FontsX $count")
            }
            when (count) {
                0 -> FontFamilyX()
                1-> FontGoogleX()

            }
        }

    }

    @Composable
    private fun FontFamilyX() {
        val firaSansFamily = FontFamily(
            Font(R.font.he_feng, FontWeight.Light),
            Font(R.font.he_feng, FontWeight.Bold),
            Font(R.font.qing_niao, FontWeight.Light),
        )
        Column {
            Text("Hello World", fontFamily = FontFamily.Serif)
            Text("Hello World", fontFamily = FontFamily.SansSerif)
            Text("Hello World", fontFamily = firaSansFamily)
        }
    }

    @Composable
    private fun FontGoogleX() {
        val provider = GoogleFont.Provider(
            providerAuthority = "com.google.android.gms.fonts",
            providerPackage = "com.google.android.gms",
            certificates = R.array.com_google_android_gms_fonts_certs
        )
        val fontName = GoogleFont("Lobster Two")
        val fontFamily = FontFamily(
            Font(googleFont = fontName, fontProvider = provider)
        )
        Text("Hello World", fontFamily = FontFamily.SansSerif)
        Text("Hello World", fontFamily = fontFamily)
        val MyTypography = Typography(
            labelMedium = TextStyle(
                fontFamily = fontFamily, fontWeight = FontWeight.Normal, fontSize = 12.sp/*...*/
            ),
            labelLarge = TextStyle(
                fontFamily = fontFamily,
                fontWeight = FontWeight.Bold,
                letterSpacing = 2.sp,
                /*...*/
            ),
            displayMedium = TextStyle(
                fontFamily = fontFamily, fontWeight = FontWeight.SemiBold/*...*/
            ),
        )

    }
}